﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kotonoha.Server.Search {
    public abstract class BasePosition {
        public virtual long Id { get; set; }
        public virtual PositionType Type { get; set; }
        public virtual Substring Substring { get; set; }
        public virtual int Distance { get; set; }

        public virtual bool Equals(BasePosition other) {
            if (ReferenceEquals(null, other)) {
                return false;
            }
            if (ReferenceEquals(this, other)) {
                return true;
            }
            return other.Id == Id;
        }

        public override bool Equals(object obj) {
            if (ReferenceEquals(null, obj)) {
                return false;
            }
            if (ReferenceEquals(this, obj)) {
                return true;
            }
            if (obj.GetType() != typeof (BasePosition)) {
                return false;
            }
            return Equals((BasePosition) obj);
        }

        public override int GetHashCode() {
            return Id.GetHashCode();
        }
    }

    public abstract class TypedPosition<T> : BasePosition {
        public virtual T Value { get; set; }
    }

    public enum PositionType {
        Begin = 0,
        Middle = 1,
        End = 2
    }
}
